xlv.imp.mvc={
	implement:function(){
	},
	method:{
		mvc_properties:{
		},
		mvc_getModel:function(dm_name){
			return xlv.util.dmSearch(this,(dm_name||this.$P.dmName));
		},
		mvc_addListener:function(){
			var dm=this.mvc_getModel();
			if(dm)dm.addListener(this);
		},
		mvc_removeListener:function(){
			var dm=this.mvc_getModel();
			if(dm)dm.removeListener(this);
		},
		mvc_isModel:function(dm){
			return (dm && dm.getName()==this.$P.dmName);
		},
		mvc_valueFromModel:function(dm){
			return (this.mvc_isModel(dm)&&this.$P.dmPath) ? dm.getValue(this.$P.dmPath) : null;
		},
		mvc_valueToModel:function(value,dm){
			if(this.mvc_isModel(dm)&&this.$P.dmPath) dm.setValue(value,this.$P.dmPath);
		},
		mvc_valueToView:function(value){
		},
		mvc_valueFromView:function(){
		},
		mvc_beforeModelChanged:function(dm,notify,memo){
		},
		mvc_modelChanged:function(dm,notify,memo){
			if(notify=='nodeChanged') {
				if(memo.type=='update' && this.$P.dmPath && memo.src && !this.$P.dmPath.endsWith(memo.src.nodeName)) return;
				this.mvc_modelToView(dm);
			}
		},
		mvc_afterModelChanged:function(dm,notify,memo){
			switch(notify){
			case 'setChanged': if(dm.isExtend('xlv.obj.rowset'))return;
			case 'rowChanged':
			case 'cursorMove':
				this.mvc_modelToView(dm);
				break;
			}
			this.mvc_enableControl(dm);
		},
		mvc_modelToView:function(dm){
			var dm=(dm||this.mvc_getModel());
			if(dm)this.mvc_valueToView(this.mvc_valueFromModel(dm));
		},
		mvc_viewToModel:function(dm){
			var dm=(dm||this.mvc_getModel());
			if(dm)this.mvc_valueToModel(this.mvc_valueFromView(),dm);
		},
		mvc_enableControl:function(dm){
		}
	}
};

